package com.zaoniao.enstudy.api.vo;

import com.zaoniao.enstudy.domain.entity.Vocabulary;
import com.zaoniao.enstudy.infracore.web.PagedGridResult;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Data
@Schema(name = "词汇表响应对象")
public class VocabularyVo {

    @Schema(description = "词汇表唯一标识", name = "vocabularyId")
    private Integer vocabularyId;

    @Schema(description = "用户唯一标识openId", name = "userId")
    private String userId;

    @Schema(description = "词汇表名称", name = "vocabularyName")
    private String vocabularyName;

    @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
    public interface Converter {

        VocabularyVo.Converter INSTANCE = Mappers.getMapper(VocabularyVo.Converter.class);

        /**
         * doList转voList
         *
         * @param vocabularies -
         * @return -
         */
        List<VocabularyVo> do2VoList(List<Vocabulary> vocabularies);

        @Mapping(source = "id", target = "vocabularyId")
        VocabularyVo do2vo(Vocabulary vocabulary);

        PagedGridResult<VocabularyVo> do2voPage(PagedGridResult<Vocabulary> pagedGridResult);
    }
}
